package com.jiangyg.mall.member.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.member.dao.MemberCollectSpuDao;
import com.jiangyg.mall.member.dto.MemberCollectSpuDTO;
import com.jiangyg.mall.member.entity.MemberCollectSpu;
import com.jiangyg.mall.member.vo.MemberCollectSpuVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MemberCollectSpuServiceImpl extends BaseServiceImpl<MemberCollectSpuDao, MemberCollectSpu> implements MemberCollectSpuService {

    @Autowired
    public MemberCollectSpuServiceImpl(MemberCollectSpuDao memberCollectSpuDao) {
        super(memberCollectSpuDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<MemberCollectSpuVO> selectPagination(Pagination<MemberCollectSpuVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, MemberCollectSpuVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(MemberCollectSpuDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public MemberCollectSpuVO selectById(Long memberCollectSpuId) throws Exception {
        return this.executeSelectById(memberCollectSpuId, MemberCollectSpuVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> memberCollectSpuIds) {
        return this.baseMapper.deleteBatchIds(memberCollectSpuIds) > 0;
    }

}
